<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
  </head>
  <body>
    <ul class="joke"></ul>
  </body>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
  <script>
    $.ajax({
      type: "get",
      url: "http://v.juhe.cn/joke/content/list.php",    
      dataType: "jsonp",
      data: {
        sort: "asc",
        time: "1418816972",
        //page:2,
        //pagesize:5,
        //随机取值
        page: Math.round(Math.ceil(Math.random() * 19 + 1)), //[1,20]
        pagesize: Math.round(Math.ceil(Math.random() * 19 + 1)), //[1,20]
        key: "0fe4a346bf75c1414f4d73b611fc0d8f",
      },
    })
      .then(function (res) {
        console.log(res.result);
        console.log(res.result.data);
        console.log(res.result.data[0].content);
        var jokes = res.result.data;
        for (var i in jokes) {
          var jokesData = $("<li>" + jokes[i].content + "</li>");
          $(".joke").append(jokesData);
        }
      })
      .catch(function (err) {
        if (err.status == 404) {
          location.href = "404.html";
        }
      });
  </script>
</html>
